package com.dididoctor.doctor.Activity.Usercentre.MyService;

import android.view.View;
import android.widget.CompoundButton;
import android.widget.ToggleButton;

import com.dididoctor.doctor.Activity.Main.Consult;
import com.dididoctor.doctor.MV.EduActivity;
import com.dididoctor.doctor.R;

/**
 * Created by boy on 2016/4/18.
 */
public class MyServiceActiyity extends EduActivity implements MyServiceView {
    private ToggleButton mTogBtn2, mTogBtn3;
    private boolean switchone, switchtwo;
    private MyServicePresenter presenter;

    @Override
    public void init() {
        setText(R.id.tv_title, "我的服务");
        mTogBtn2 = (ToggleButton) findViewById(R.id.mTogBtn2);
        mTogBtn3 = (ToggleButton) findViewById(R.id.mTogBtn3);
        mTogBtn2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (mTogBtn2.isChecked()) {
                    switchone = true;
                } else {
                    switchone = false;

                }
                presenter.updatestatus("2", switchone);
            }
        });
        mTogBtn3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (mTogBtn3.isChecked()) {
                    switchtwo = true;
                } else {
                    switchtwo = false;

                }
                presenter.updatestatus("3", switchtwo);
            }
        });
        presenter = new MyServicePresenter(this, this);
        presenter.getdoctorInfo();

    }

    @Override
    public void onClickEvent(View view) {

    }

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_myservice);

    }


    @Override
    public void updatestatesucced(String type, boolean status) {
        if ("2".equals(type)) {
            mTogBtn2.setChecked(status);
            if ("3".equals(type)) {
                mTogBtn2.setChecked(status);
            }
        }

    }

    @Override
    public void updatestatefail() {

    }

    @Override
    public void getdoctorsucced(Consult consult) {
        if (consult != null) {
            if ("1".equals(consult.getCallSwitch())) {
                mTogBtn2.setChecked(true);
            } else {
                mTogBtn2.setChecked(false);
            }
            if ("1".equals(consult.getIsSign())) {
                mTogBtn3.setChecked(true);
            } else {
                mTogBtn3.setChecked(false);
            }
        }
    }

    @Override
    public void getdoctorfail() {

    }
}
